﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace TestEngine
{
    class CollisionManager
    {
        List<Actor> possibleActors;

        public struct Collisions
        {
            public string first;
            public string second;
        }

        public CollisionManager(List<Actor> _cActors)
        {
            possibleActors = _cActors;
        }

        public List<Collisions> getAll()
        {
            List<Collisions> sceneCollisions = new List<Collisions>();

            for (int i = 0; i < possibleActors.Count; i++)
            {
                for (int j = i + 1; j < possibleActors.Count; j++)
                {
                    if (possibleActors[i].collider.getRect().Intersects(possibleActors[j].collider.getRect()))
                    {
                        string first = possibleActors[i].name;
                        string second = possibleActors[j].name;
                        Collisions col = new Collisions();
                        col.first = first;
                        col.second = second;
                        sceneCollisions.Add(col);
                    }
                }
            }
            return sceneCollisions;
        }

        public void drawAll(SpriteBatch sb, SpriteFont sf)
        {
            float advance = 0;
            List<Collisions> tempDraw = getAll();
            foreach (Collisions col in tempDraw)
            {
                sb.DrawString(sf, col.first + " " + col.second, new Vector2(250, advance), Color.White);
                advance += 15;
            }
        }
    }
}
